define(['bootstrapTable','layer','formValidate'],function (bootstrapTable,layer,formValidate) {
    return {
        init: function () {
            showData();
            /*定时刷新页面*/
            setInterval(function () {
                $('#comeFromTable').bootstrapTable("refresh");
            },10000);
        }
    };
    function showData(){
        var today = getNowFormatDate2();
        $('#comeFromTable').bootstrapTable({
            url: "/visitorFromController/findByModal", // 获取表格数据的url
            method:'post',
            cache: false,       // 设置为 false 禁用 AJAX 数据缓存， 默认为true
            striped: true,      //表格显示条纹，默认为false
            pagination: false,   // 在表格底部显示分页组件，默认false
            contentType:'application/x-www-form-urlencoded',
            sidePagination: 'server', // 设置为服务器端分页，必要
            queryParamsType : "",
            queryParams:function(params){
                return tem={
                    calledDate: today,
                    sceneCode: '52011501'
                }
                /*return tem={
                    rows:params.pageSize,
                    page:params.pageNumber,
                    calledDate: today,
                    sceneCode: '52011501'
                }*/
            },
            clickToSelect:false,
            columns: [
                {
                    title: '序号',
                    align: 'center',
                    formatter:showNumber,
                    width:'1%'
                },
                {
                    field: 'comeFrom',
                    title: '地市',
                    align: 'center',
                    valign: 'middle',
                    width:'16%'

                }, {
                    field: 'num',
                    title: "游客数(人)",
                    align: 'center',
                    valign: 'middle',
                    width:'16%'
                }, {
                    field: 'rate',
                    title: "占比",
                    align: 'center',
                    valign: 'middle',
                    width: '22%'
                }
            ],
            onLoadSuccess: function(data){  //加载成功时执行

            },
            onLoadError: function(){  //加载失败时执行
                //console.info("加载数据失败");
            }
        });
    }
    function getNowFormatDate() {
        var date = new Date();
        //var seperator1 = "-";
        var year = date.getFullYear();
        var month = date.getMonth() + 1;
        var strDate = date.getDate();
        if (month >= 1 && month <= 9) {
            month = "0" + month;
        }
        if (strDate >= 0 && strDate <= 9) {
            strDate = "0" + strDate;
        }
        var currentdate = year + ' 年 ' + month + ' 月 ' + strDate + ' 日';
        return currentdate;
    }
    function getNowFormatDate2() {
        var date = new Date();
        var seperator1 = "-";
        var year = date.getFullYear();
        var month = date.getMonth() + 1;
        var strDate = date.getDate();
        if (month >= 1 && month <= 9) {
            month = "0" + month;
        }
        if (strDate >= 0 && strDate <= 9) {
            strDate = "0" + strDate;
        }
        var currentdate = year + seperator1 + month + seperator1 + strDate;
        return currentdate;
    }
    function showNumber(value, row, index){
        //var options = $('#comeFromTable').bootstrapTable('getOptions');
        //return options.pageSize*(options.pageNumber-1)+index + 1;
        return index + 1;
    }
});